
*===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== =====* 
*===== ===== ===== ===== ===== 	RCFS replication DO file 	 ===== ===== ===== ===== ===== ===== =====* 
*===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== ===== =====* 

*===== ===== 	Setup required to begin 	===== ===== =====* 
global MyFolder `"INSERT_file_directory_HERE"'
 *---> Define the global variable "MyFolder" to set the file directory where all data files should be stored (replace "INSERT_file_directory_HERE" with the correct directory, e.g., "C:\Users\RCFS\Data"). 
 
global regstats b(%10.3f) p(%8.3f) stats(N r2_a r2_p , fmt(%9.0f %8.3f %8.3f) label("N" "Adj R2" "Pseudo R2"))  star(* 0.10 ** 0.05 *** 0.01) modelwidth(15) compress nogaps
 *---> Formatting (no change required) 
 
*== NOTE: Some of the analyses below make use of Stata user-contributed commands, which may have to be installed (if not installed, a Stata error message will show up). 
 
*===== ===== ===== ===== ===== ===== ===== ===== ===== =====* 


cd "$MyFolder"


*** =================================================================== ***
*** === TABLE 1 – Summary statistics === ***
*** =================================================================== ***
use "rcfs-data-1-deal-rev", clear
global target   "lnta mtb lev2 cf rnd" 
global deal     "hostile ttermfee_dum competed_bid tender sameindus_sdc rel_size" 
global acquirer "a_lnta a_mtb a_lev2 a_cf a_rnd"
global misval   "a_misval1 a_misval2 a_misval3"
global other    "stock_pct advisorsT_top8 advisorsT_ntop8 collar1 FP diff_car_dollar"


eststo clear
*** Deal characteristics
estpost tabstat ma1casho ma1stocko $deal  if !mi(stock_pct) ,listwise statistics (count mean p25 p50 p75 sd) columns(statistics)
esttab, cells("count mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) sd(fmt(3))") noobs nonumber replace

*** Target characteristics
estpost tabstat  $target    if !mi(stock_pct),listwise statistics (count mean p25 p50 p75 sd) columns(statistics)
esttab, cells("count mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) sd(fmt(3))") noobs nonumber replace

*** Bidder characteristics
estpost tabstat  $acquirer  if !mi(stock_pct),listwise statistics (count mean p25 p50 p75 sd) columns(statistics)
esttab, cells("count mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) sd(fmt(3))") noobs nonumber replace

*** Information asymmetry
global infoasym "a_info_asym recent_acq1 recent_SEO local_deal1 indus_comple"
estpost summarize $infoasym  if !mi(stock_pct), detail
esttab, cells("count mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) sd(fmt(3))") noobs

*** Misvaluation of bidder shares
global misval   "a_misval1 a_misval2 a_misval3 shortratio"
estpost summarize $misval  if !mi(stock_pct), detail
esttab, cells("count mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) sd(fmt(3))") noobs

*** Other variables
global adv   "stock_pct advisorsT_top8 advisorsT_ntop8"
estpost summarize $adv  if !mi(stock_pct), detail
esttab, cells("count mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) sd(fmt(3))") noobs

global value   "collar1 FP diff_car_dollar"
estpost summarize $value, detail
esttab, cells("count mean(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) sd(fmt(3))") noobs




*** =================================================================== ***
*** === TABLE 2 – Targets' institutional ownership and the consideration structure === ***
*** =================================================================== ***
use "rcfs-data-2-deal-zip",clear 
global deal1     "hostile ttermfee_dum competed_bid tender sameindus_sdc" 

*** Column (1),(2),(4),(5) of TABLE 2 
keep if inlist(ma1ml,1,2,3)
keep if !mi(stock_pct)
eststo A: quietly  mlogit ma1ml d4n_all  $deal1  $target  i.fyear i.ffi48 
eststo C: quietly  mlogit ma1ml d4n_all  $deal  $target  $acquirer   i.fyear i.ffi48 if apstatus=="Public"
esttab A C , order(d4n_all $deal $target ) drop(19* 2*  *ffi* _cons) $regstats replace label

*** Column (3),(6) of TABLE 2 
eststo B: quietly  tobit stock_pct d4n_all   $deal1  $target  i.fyear i.ffi48 
eststo D: quietly  tobit stock_pct d4n_all   $deal $target $acquirer  i.fyear i.ffi48  if apstatus=="Public"
esttab B D, $regstats label drop(19* 2*  *ffi* _cons) 

/* Marginal effect from the multinomial logit model
eststo A: quietly  mlogit ma1ml d4n_all   $deal $target $acquirer  i.fyear i.ffi48 if !mi(stock_pct), base(1)
forval j = 1/3 {
est res A
margins, dydx(d4n_all) pr(out(`j')) post
est sto mj`j'
}
esttab A, order(d4n_all) drop(19* 2* *fyear* *ffi*  _cons) label $regstats replace
*/




*** =================================================================== ***
*** === TABLE 3 – IV estimation using Russell index reconstitution === ***
*** =================================================================== ***
use "rcfs-data-2-deal-zip",clear 
label variable com           "Completed [0;1]"
label variable sameindus_sic "Same industry"
label variable rel_size      "Relative size"
label variable sameindus_sic "Same industry"
label variable rel_size      "Relative size"
label variable com           "Completion [0;1]"
label variable d4n_all       "Change in total IO" 
label variable d4n_qix       "Change in QIX IO" 
label variable d4n_tra       "Change in TRA IO" 
label variable d4n_ded       "Change in DED IO" 


* MAIN SET OF CONTROL VARIABLES FOR THE DEAL LEVEL TESTS
global target   "lnta mtb lev2 cf rnd" 
global deal1    "hostile ttermfee_dum competed_bid tender sameindus_sdc"
global deal     "hostile ttermfee_dum competed_bid tender sameindus_sdc rel_size" 
global acquirer "a_lnta a_mtb a_lev2 a_cf a_rnd"

capture gen ln_tot_mktcap_r3   = ln(tot_mktcap_r3)
label variable ln_tot_mktcap_r3 "ln(May mcap)"
capture gen tot_mktcap_r3_frac = tot_mktcap_r3/1000
gen d_rank1 = d_rank/100
label variable d_rank1 "d_rank1 D.rank(t-1;t)/100"
gen d_rank1sqr = d_rank1^2
label variable d_rank1sqr "d_rank1 squared"
gen d_ranksqr = d_rank^2
*as rel_size needs acquirer info
global deal1    "hostile ttermfee_dum competed_bid tender  sameindus_sdc"
gen public_bidder = (apstatus =="Public")

// STOCK-ONLY PROB: IV
ranktest (d4n_all) (rus_12 rus_21 d_rank1 d_rank1sqr), wald null robust 

eststo a: qui  ivreg2 ma1stocko (d4n_all = rus_12 rus_21 d_rank1 d_rank1sqr) ///
ln_tot_mktcap_r3 $deal1 $target  i.fyear i.ffi48,first savefirst robust
 *esttab _ivreg2_d4n_all a, $regstats drop( _cons *fyear* *ffi* ) replace label order(d4n_all)

eststo b: qui  ivreg2 stock_pct (d4n_all = rus_12 rus_21 d_rank1 d_rank1sqr) ///
ln_tot_mktcap_r3 $deal1 $target  i.fyear i.ffi48,first savefirst robust
 *esttab _ivreg2_d4n_all a b, $regstats drop( _cons *fyear* *ffi* ) replace label order(d4n_all)

esttab _ivreg2_d4n_all a b, $regstats order(d4n_all rus_12 rus_21 d_rank1 d_rank1sqr ln_tot_mktcap_r3 $deal1 $target) drop( _cons *fyear* *ffi* ) label replace

/* stats following the test
ivregress 2sls ma1stocko (d4n_all=rus_12 rus_21 d_rank1 d_rank1sqr) ///
ln_tot_mktcap_r3 $target $deal1 i.fyear i.ffi48,robust
estat overid 
estat endog
*/




*** =================================================================== ***
*** === TABLE 4 – Different types of institutions === ***
*** =================================================================== ***
use "rcfs-data-1-deal-rev", clear
global target   "lnta mtb lev2 cf rnd" 
global deal     "hostile ttermfee_dum competed_bid tender sameindus_sdc rel_size" 
global acquirer "a_lnta a_mtb a_lev2 a_cf a_rnd"
eststo A: quietly tobit stock_pct d4n_all   $deal $target $acquirer  i.fyear i.ffi48 
eststo B: quietly tobit stock_pct d4n_mor d4n_nonmor   $deal $target $acquirer  i.fyear i.ffi48 
eststo C: quietly tobit stock_pct d4n_qixded d4n_tra   $deal $target $acquirer  i.fyear i.ffi48
eststo D: quietly tobit stock_pct d4n_ilti d4n_nonilti  $deal $target $acquirer  i.fyear i.ffi48
esttab A B C D , order(d4n_* $deal $target $acquirer ) drop(1* 2*  *ffi* _cons) $regstats replace




*** =================================================================== ***
*** === TABLE 5 – Institutions' cross-holdings of bidders and targets === ***
*** =================================================================== ***
eststo A: quietly tobit stock_pct d4n_all  $deal $target $acquirer  top5count i.fyear i.ffi48 
eststo B: quietly tobit stock_pct d4n_all  $deal $target $acquirer  top10count i.fyear i.ffi48 
eststo C: quietly tobit stock_pct d4n_all  $deal $target $acquirer  top20count i.fyear i.ffi48 
eststo D: quietly tobit stock_pct d4n_all  $deal $target $acquirer  ta_crossIO i.fyear i.ffi48
eststo E: quietly tobit stock_pct d4n_all  $deal $target $acquirer  ta_crossIO_1pct i.fyear i.ffi48
// eststo F: quietly tobit stock_pct d4n_all  $deal $target $acquirer  ac_crossIO i.fyear i.ffi48
// eststo G: quietly tobit stock_pct d4n_all  $deal $target $acquirer  ac_crossIO_1pct i.fyear i.ffi48
esttab A B C D E, label $regstats drop(19* 2*  *ffi* _cons)  order(d4n_all top5count top10count top20count ta_crossIO ta_crossIO_1pct $deal $target $acquirer ) 




*** =================================================================== ***
*** === TABLE 6 – Information asymmetry and the stock-based payment === ***
*** =================================================================== ***
*** Panel A: Composite proxy for bidder information asymmetry
eststo A: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_info==0
eststo B: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_info==1
esttab A B ,  order(d4n_all) drop(19* 2* *fyear* *ffi*  _cons) label $regstats replace


*** Panel B: Other proxies for bidder information asymmetry
eststo A: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if recent_acq1==1
eststo B: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if recent_acq1==0
eststo C: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if recent_SEO==1
eststo D: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if recent_SEO==0
esttab A B C D,  order(d4n_all $deal $target $acquirer ) drop(19* 2* *fyear* *ffi*  _cons) label $regstats replace


*** Panel C: Proxies for deal-level information asymmetry
eststo E: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if local_deal1==1
eststo F: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if local_deal1==0
eststo G: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_comple==1
eststo H: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_comple==0
esttab E F G H,  order(d4n_all $deal $target $acquirer ) drop(19* 2* *fyear* *ffi*  _cons) label $regstats replace




*** =================================================================== ***
*** === TABLE 7 – Stock mispricing                                  === ***
*** =================================================================== ***
eststo A: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_misval1==1
eststo B: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_misval1==0
eststo C: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_misval2==1
eststo D: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_misval2==0
eststo E: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_misval3==1
eststo F: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_misval3==0
esttab A B C D E F , order(d4n_all) drop(19* 2* *fyear* *ffi*  _cons) label $regstats replace


eststo A: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_short ==1
eststo B: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_short ==0
esttab A B , order(d4n_all) drop(19* 2* *fyear* *ffi*  _cons) label $regstats replace




*** =================================================================== ***
*** === TABLE 8 – Information asymmetry and target-side adverse selection risk  === ***
*** =================================================================== ***
*** Panel A: Composite proxy for target information asymmetry
eststo A: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_info_t==0
eststo B: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_info_t==1
esttab A B ,  order(d4n_all) drop(19* 2* *fyear* *ffi*  _cons) label $regstats replace

*** Panel B: Two-sided information asymmetry
eststo A: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_info_t==1 & high_info == 1
eststo B: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_info_t==0 & high_info == 1
eststo A1: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_info_t==1 & high_info == 0
eststo B1: quietly tobit stock_pct d4n_all $deal $target $acquirer  i.fyear i.ffi48 if high_info_t==0 & high_info == 0
esttab B1 A1 B A,  order(d4n_all) drop(19* 2* *fyear* *ffi*  _cons) label $regstats replace




*** =================================================================== ***
*** === TABLE 9 – Institution-level ex-post share retention rates   === ***
*** =================================================================== ***
use "rcfs-data-3-retention", clear 
global inst      "acar11_MM car11_MM comdays holding_value_in_mgrport inst_size"
*** Panel A: Institutional-level baseline results
eststo a: quietly reghdfe post_retention d4c_all_inst $target $acquirer $deal $inst, absorb(fyear ffi48) 
eststo b: quietly reghdfe pre_retention d4c_all_inst $target $acquirer $deal $inst, absorb(fyear ffi48) 
esttab a b, $regstats drop(_cons) order( d4c_all_inst  $deal $inst $target $acquirer) label


*** Panel B: Partitioning by combined CARs
eststo a: quietly reghdfe post_retention d4c_all_inst $target $acquirer $deal $inst if ccar_11 >0, absorb(fyear ffi48) 
eststo b: quietly reghdfe post_retention d4c_all_inst $target $acquirer $deal $inst if ccar_11 <0, absorb(fyear ffi48) 
eststo c: quietly reghdfe pre_retention d4c_all_inst $target $acquirer $deal $inst  if ccar_11 >0, absorb(fyear ffi48) 
eststo d: quietly reghdfe pre_retention d4c_all_inst $target $acquirer $deal $inst  if ccar_11 <0, absorb(fyear ffi48) 
esttab a b c d, $regstats drop(_cons) order( d4c_all_inst  $deal $inst $target $acquirer) label


*** Panel C: Partitioning by post-merger long-term performance
*--- CHANGE ROA ---*
eststo a: quietly reghdfe post_retention d4c_all_inst $target $acquirer $deal $inst if high_aroa3==1, absorb(fyear ffi48) 
eststo b: quietly reghdfe post_retention d4c_all_inst $target $acquirer $deal $inst if low_aroa3==1, absorb(fyear ffi48) 
eststo c: quietly reghdfe pre_retention d4c_all_inst $target $acquirer $deal $inst  if high_aroa3==1, absorb(fyear ffi48) 
eststo d: quietly reghdfe pre_retention d4c_all_inst $target $acquirer $deal $inst  if low_aroa3==1, absorb(fyear ffi48) 
esttab a b c d, $regstats drop(_cons) order( d4c_all_inst  $deal $inst $target $acquirer) label


*--- CHANGE SLG ---*
eststo a: quietly reghdfe post_retention d4c_all_inst $target $acquirer $deal $inst if high_aslg3==1, absorb(fyear ffi48) 
eststo b: quietly reghdfe post_retention d4c_all_inst $target $acquirer $deal $inst if low_aslg3==1, absorb(fyear ffi48) 
eststo c: quietly reghdfe pre_retention d4c_all_inst $target $acquirer $deal $inst  if high_aslg3==1, absorb(fyear ffi48) 
eststo d: quietly reghdfe pre_retention d4c_all_inst $target $acquirer $deal $inst  if low_aslg3==1, absorb(fyear ffi48) 
esttab a b c d, $regstats drop(_cons) order( d4c_all_inst  $deal $inst $target $acquirer) label

*--- CHANGE COGS ---*
eststo a: quietly reghdfe post_retention d4c_all_inst $target $acquirer $deal $inst if high_acogs3==1, absorb(fyear ffi48) 
eststo b: quietly reghdfe post_retention d4c_all_inst $target $acquirer $deal $inst if low_acogs3==1, absorb(fyear ffi48) 
eststo c: quietly reghdfe pre_retention d4c_all_inst $target $acquirer $deal $inst  if high_acogs3==1, absorb(fyear ffi48) 
eststo d: quietly reghdfe pre_retention d4c_all_inst $target $acquirer $deal $inst  if low_acogs3==1, absorb(fyear ffi48) 
esttab a b c d, $regstats drop(_cons) order( d4c_all_inst  $deal $inst $target $acquirer) label




*** =================================================================== ***
*** === TABLE 10 – Targets' demand for top-tier M&A advisors   === ***
*** =================================================================== ***
use "rcfs-data-1-deal-rev", clear
global target   "lnta mtb lev2 cf rnd" 
global deal     "hostile ttermfee_dum competed_bid tender sameindus_sdc rel_size" 
global acquirer "a_lnta a_mtb a_lev2 a_cf a_rnd"
global advisorX "ln_dealvalue stock_pct"


eststo O: quietly logit advisorsT_top8 c.d4n_all $advisorX $deal $target $acquirer i.fyear i.ffi48   ,  clus(gvkey)
 margins, dydx(d4n_all) at((means) _all (asobs) d4n_all)  noatlegend  
eststo A: quietly logit advisorsT_top8 c.d4n_all $advisorX $deal $target $acquirer  i.fyear i.ffi48  if high_info ==1 ,   clus(gvkey)
 margins, dydx(d4n_all) at((means) _all (asobs) d4n_all)  noatlegend  
eststo B: quietly logit advisorsT_top8 c.d4n_all $advisorX $deal $target $acquirer  i.fyear i.ffi48  if high_info ==0  ,  clus(gvkey)
 margins, dydx(d4n_all) at((means) _all (asobs) d4n_all)  noatlegend  
eststo O1: quietly reghdfe advisorsT_ntop8 c.d4n_all $advisorX $deal $target $acquirer  ,  absorb(i.fyear i.ffi48 )   clus(gvkey)
eststo A1: quietly reghdfe advisorsT_ntop8 c.d4n_all $advisorX $deal $target $acquirer  if high_info ==1 ,  absorb(i.fyear i.ffi48 )  clus(gvkey)
eststo B1: quietly reghdfe advisorsT_ntop8 c.d4n_all $advisorX $deal $target $acquirer  if high_info ==0 ,  absorb(i.fyear i.ffi48 )  clus(gvkey)
esttab O O1 A A1 B B1, $regstats order(*d4n_all*) label replace drop(*ffi* *fyear*)




*** =================================================================== ***
*** === TABLE 11 – Design of collar agreement in stock deals   === ***
*** =================================================================== ***
capture drop collar_type
gen collar_type = 0 if !mi(collar1)
replace collar_type = 1 if FP == 1
replace collar_type = 2 if FEX == 1


eststo O:  qui logit collar1 c.d4n_all  $deal $target $acquirer  i.fyear i.ffi48   
eststo B:  qui logit FP d4n_all  $deal $target $acquirer i.fyear i.ffi48 
eststo B1: qui logit FEX d4n_all  $deal $target $acquirer i.fyear i.ffi48
eststo C:  qui mlogit collar_type c.d4n_all  $deal $target $acquirer i.fyear i.ffi48  

*** Column (1), (2), (3) of Table 11
esttab O B B1  , $regstats drop(_cons *fyear* *ffi48*) label replace  

*** Column (4), (5) of Table 11
esttab C , $regstats drop(_cons *fyear* *ffi48*) label replace

/* MARGINAL EFFECT 
qui: logit collar1 d4n_all  $deal $target $acquirer  i.fyear i.ffi48  
 margins, dydx(d4n_all) at((means) _all (asobs) d4n_all)  noatlegend  
qui: logit FP d4n_all  $deal $target $acquirer  i.fyear i.ffi48  
 margins, dydx(d4n_all) at((means) _all (asobs) d4n_all)  noatlegend  
qui: logit FEX d4n_all  $deal $target $acquirer  i.fyear i.ffi48  
 margins, dydx(d4n_all) at((means) _all (asobs) d4n_all)  noatlegend  
qui: eststo A: mlogit collar_type c.d4n_all  $deal $target $acquirer i.fyear i.ffi48   , base(0)
  margins, dydx(d4n_all) at((means) _all (asobs) d4n_all)  noatlegend  
forval i = 1/2 {
est res A
margins, dydx(d4n_all) pr(out(`i')) post
est sto mi`i'
} 
*/




*** =================================================================== ***
*** === TABLE 12 – – Targets' share of synergy gains   === ***
*** =================================================================== ***
preserve
replace diff_car_dollar = diff_car_dollar/100
eststo A: quietly reghdfe diff_car_dollar d4n_all $deal $target $acquirer  , absorb(fyear ffi48) clus(ffi48 a_ffi48)
eststo C: quietly reghdfe diff_car_dollar d4n_mor c.d4n_nonmor $deal $target $acquirer  , absorb(fyear ffi48 ) clus(ffi48 a_ffi48)
eststo D: quietly reghdfe diff_car_dollar d4n_qixded c.d4n_tra $deal $target $acquirer  , absorb(fyear ffi48 ) clus(ffi48 a_ffi48)
eststo B: quietly reghdfe diff_car_dollar d4n_ilti c.d4n_nonilti $deal $target $acquirer , absorb(fyear ffi48 )  clus(ffi48 a_ffi48)
esttab A  C D B, $regstats label replace order(d4n*)
restore






*** =================================================================== ***
*** === GRAPHS  === ***
*** =================================================================== ***

{ //*** ===  Figure 1 – Time trends in M&A offers by payment methods
use "rcfs-data-1-deal-rev",clear
**** CHECK AS THE ALL-CASH FRACTION IS TOO HIGH
* ANNUAL TOTAL NUMBER OF BIDS AND DISTRIBUTION ACROSS PAYMENT METHODS
gen cashdeal 			 = (finalstr=="CASHO")
gen stockdeal			 = (inlist(finalstr,"SHARES","CHOICESH"))
gen mixed 			 	 = (inlist(finalstr,"HYBRID","CHOICECS","OTHER"))

bys cyear: egen n        = count(dealnumber)
bys cyear: egen ncash 	 = count(cashdeal)  if cashdeal==1
bys cyear: egen nstock	 = count(stockdeal) if stockdeal==1
bys cyear: egen nmixed	 = count(mixed)     if mixed==1

set scheme s1color 
twoway (bar n cyear, sort fcolor(gs10) lcolor(gs10)) (line ncash cyear,sort lpattern(-.) lc(blue)) ///
(line nstock cyear,sort lc(black)) (line nmixed cyear,sort lpattern(-) lc(green)) if inrange(cyear, 1985,2018), ///
ylabel(,grid) xtitle(Year) xlabel(1985(2)2018,angle(50)) xscale(range(1985 2015)) ///
ytitle("Number of deals ") legend(lab(1 "Total deals") lab(2 "Cash-only deals") ///
lab(3 "Stock-only deals") lab(4 "Mixed"))
// graph export "$graphs\F1.png", as(pdf) replace
}
...


{ //*** ===  Figure 2 – Time trends in institutional ownership
/*
use "$maindata\Data_raw\IO_qrt.dta",clear
joinby lpermno using "$maindata\Data_main\rcfs-data-1-deal-rev"
merge m:1 lpermno rdate using "F:\S34\Mor\all", nogen keep(1 3) keepusing(ior_mor)
merge m:1 lpermno rdate using "F:\S34\ILTI\ILTIs" , nogen keep(1 3) keepusing(ilti_m_own)
save "rcfs-data-6-trends", replace
*/

use "rcfs-data-6-trends", clear
gen ior_qixded = ior_qix+ior_ded
bys rdate: egen a= mean(ior_all)
bys rdate: egen c= mean(ior_mor)
bys rdate: egen f= mean(ior_qixded)
bys rdate: egen g= mean(ilti_m_own)

foreach i in a c  f g {
replace `i' = `i'*100
}

gen qr=qofd(rdate)
format qr %tq
set scheme s1color
twoway (line a qr, sort) (line c qr,sort lpattern(dash)) (line f qr,sort lpattern(longdash)) (line g qr,sort lpattern(shortdash)) if inrange(year(rdate),1984,2017), ///
ylabel(,grid) xtitle(Quarter) xlabel(#16,angle(50)) ///
ytitle("Institutional ownership (%)") ///
legend(lab(1 "Total IO") lab(2 "Monitoring IO") ///
lab(3 "QIXDED IO") lab(4 "Indep-block IO"))
drop a c f g qr
// graph export "$graphs\F2_MA.png", as(png) replace
}
...


{ //*** ===  Figure 3 – Institutional ownership and stock payments in M&A offers

*** Panel A: Institutional-level baseline results
use "rcfs-data-2-deal-zip",clear 
* QUINTILES of IO
egen quant=xtile(d4n_all) if !mi(d4n_all), n(5) 
bys quant: egen ma =count(ma1) if ma1==1
bys quant: egen mas =count(ma1stocko) if ma1stocko==1
bys quant: sum ma mas if !mi(quant)

bys quant: egen ma_pct  =count(ma1) if ma1==1
bys quant: egen mas_pct =count(ma1stocko)if ma1stocko==1
replace mas_pct = mas_pct/ma_pct 

gen mas_pct1 = mas_pct if quant==5
egen mas_other = count(ma1stocko) if ma1stocko==1 &inrange(quant,1,4)
egen ma_other  = count(ma1) if ma1==1 &inrange(quant,1,4)
gen mas_pctother = mas_other/ma_other
egen stock_pc1 = mean(stock_pct) if quant==5  & ma1==1
egen stock_pcother = mean(stock_pct) if inrange(quant,1,4)  & ma1==1
sum mas_pct1 mas_pctother stock_pc1 stock_pcother // largest quantile change vs other 

*** Top-Left
set scheme s1color 
graph bar (mean) mas_pct1 (mean) mas_pctother, ///
bar(1, fcolor(maroon)) bar(2, fcolor(navy)) bar(1, lcolor(maroon)) bar(2, lcolor(navy)) ///
fysize(220) fxsize(180) bargap(60) yscale(range(0 0.4)) ytick(0(0.05)0.4) ///
legend( label(1 "Largest increase in IO") label(2 "Other") ) ///
ytitle("% of stock-only deals") ///
title("Fraction of stock-only deals") subtitle("by the change in IO") saving(A, replace) 

*** Top-Right
graph bar (mean) stock_pc1 (mean) stock_pcother, ///
bar(1, fcolor(maroon)) bar(2, fcolor(navy)) bar(1, lcolor(maroon)) bar(2, lcolor(navy)) ///
fysize(220) fxsize(180) bargap(60) yscale(range(0 0.4)) ytick(0(0.05)0.4) ///
legend( label(1 "Largest increase in IO") label(2 "Other") ) ///
ytitle("Fraction of stock") ///
title("Fraction of stock in the deal payment") subtitle("by the change in IO") saving(B, replace) 
gr combine A.gph B.gph, /* rows(2) */ ysize(7) xsize(10)  imargin(vsmall)
drop quant mas_pct1 mas_other ma_pct mas_pct ma_other mas_pctother stock_pc1 stock_pcother ma mas 


*** Panel B: Bidders are public firms only
use "rcfs-data-2-deal-zip",clear 
keep if apstatus == "Public"

* QUINTILES of IO
egen quant=xtile(d4n_all) if !mi(d4n_all), n(5) 
bys quant: egen ma =count(ma1) if ma1==1
bys quant: egen mas =count(ma1stocko) if ma1stocko==1
bys quant: sum ma mas if !mi(quant)

bys quant: egen ma_pct  =count(ma1) if ma1==1
bys quant: egen mas_pct =count(ma1stocko)if ma1stocko==1
replace mas_pct = mas_pct/ma_pct 

gen mas_pct1 = mas_pct if quant==5
egen mas_other = count(ma1stocko) if ma1stocko==1 &inrange(quant,1,4)
egen ma_other  = count(ma1) if ma1==1 &inrange(quant,1,4)
gen mas_pctother = mas_other/ma_other
egen stock_pc1 = mean(stock_pct) if quant==5  & ma1==1
egen stock_pcother = mean(stock_pct) if inrange(quant,1,4)  & ma1==1
sum mas_pct1 mas_pctother stock_pc1 stock_pcother // largest quantile change vs other 

*** Bottom-Left
set scheme s1color 
graph bar (mean) mas_pct1 (mean) mas_pctother, ///
bar(1, fcolor(maroon)) bar(2, fcolor(navy)) bar(1, lcolor(maroon)) bar(2, lcolor(navy)) ///
fysize(220) fxsize(180) bargap(60) yscale(range(0 0.5)) ytick(0(0.05)0.5) ///
legend( label(1 "Largest increase in IO") label(2 "Other") ) ///
ytitle("% of stock-only deals") ///
title("Fraction of stock-only deals") subtitle("by the change in IO") saving(A, replace) 

*** Bottom-Right
graph bar (mean) stock_pc1 (mean) stock_pcother, ///
bar(1, fcolor(maroon)) bar(2, fcolor(navy)) bar(1, lcolor(maroon)) bar(2, lcolor(navy)) ///
fysize(220) fxsize(180) bargap(60) yscale(range(0 0.4)) ytick(0(0.05)0.5) ///
legend( label(1 "Largest increase in IO") label(2 "Other") ) ///
ytitle("Fraction of stock") ///
title("Fraction of stock in the deal payment") subtitle("by the change in IO") saving(B, replace) 
gr combine A.gph B.gph, /* rows(2) */ ysize(7) xsize(10)  imargin(vsmall)
drop quant mas_pct1 mas_other ma_pct mas_pct ma_other mas_pctother stock_pc1 stock_pcother ma mas 
}
...


{ //*** ===  Figure 4: Discontinuities in institutional ownership and the targetiveness around the Russell 1000/2000 threshold

use "rcfs-data-5-panel", clear      // Bidders = [Pub]
capture gen ln_tot_mktcap_r3   = ln(tot_mktcap_r3)
label variable ln_tot_mktcap_r3 "ln(May mcap)"
capture gen tot_mktcap_r3_frac = tot_mktcap_r3/1000
gen d_rank1 = d_rank/100
label variable d_rank1 "d_rank1 D.rank(t-1;t)/100"
gen d_rank1sqr = d_rank1^2
label variable d_rank1sqr "d_rank1 squared"
gen d_ranksqr = d_rank^2

// Panel A
set scheme s1color 
preserve
rdrobust ioe_all rank if inrange(rank,750,1250) &inrange(cyear,1984,2017), c(1000) p(2)  
rdplot ioe_all rank if inrange(rank,750,1250) &inrange(cyear,1984,2017), c(1000) p(2) nbins(10) ///
graph_options(title("Sample period 1984–2018")  ylabel(,grid)  ///
ytitle("Institutional ownership (%)") xtitle("End-of-May market capitalization rank"))
graph export "$graphs\F4_A1.png", as(pdf) replace
restore

preserve
rdrobust ioe_all rank if inrange(rank,750,1250) &inrange(cyear,1984,2007), c(1000) p(2)  
rdplot ioe_all rank if inrange(rank,750,1250) &inrange(cyear,1984,2007), c(1000) p(2) nbins(10) ///
graph_options(title("Pre-banding policy period 1984–2007")  ylabel(,grid)  ///
ytitle("Institutional ownership (%)") xtitle("End-of-May market capitalization rank"))
graph export "$graphs\F4_A2.png", as(pdf) replace
restore


use "rcfs-data-5-panel", clear      // Bidders = [Pub]
capture gen ln_tot_mktcap_r3   = ln(tot_mktcap_r3)
label variable ln_tot_mktcap_r3 "ln(May mcap)"
capture gen tot_mktcap_r3_frac = tot_mktcap_r3/1000
gen d_rank1 = d_rank/100
label variable d_rank1 "d_rank1 D.rank(t-1;t)/100"
gen d_rank1sqr = d_rank1^2
label variable d_rank1sqr "d_rank1 squared"
gen d_ranksqr = d_rank^2

// Panel B
preserve
replace ma1 = ma1*100
rdrobust ma1 rank if inrange(rank,750,1250) &inrange(cyear,1984,2017), c(1000) p(2)  
rdplot ma1 rank if inrange(rank,750,1250) &inrange(cyear,1984,2017), c(1000) p(2) nbins(5) ///
graph_options(title("Probability of receiving a takeover bid (%)") ylabel(,grid) ///
ytitle("Probability (%)") xtitle("End-of-May market capitalization rank"))
graph export "$graphs\F4_B1.png", as(pdf) replace
restore

preserve
replace ma1casho = ma1casho*100
rdrobust ma1casho rank if inrange(rank,800,1200) &inrange(cyear,1984,2017), c(1000) p(2)  
rdplot ma1casho rank if inrange(rank,800,1200) &inrange(cyear,1984,2017), c(1000) p(2) nbins(5) ///
graph_options(title("Probability of receiving a cash-only bid (%)")  ylabel(,grid) ///
ytitle("Probability (%)") xtitle("End-of-May market capitalization rank"))
graph export "$graphs\F4_B2.png", as(pdf) replace
restore

preserve
replace ma1mixed = ma1mixed*100
rdrobust ma1mixed rank if inrange(rank,800,1200) &inrange(cyear,1984,2017), c(1000) p(2)  
rdplot ma1mixed rank if inrange(rank,800,1200) &inrange(cyear,1984,2017), c(1000) p(2) nbins(5) ///
graph_options(title("Probability of receiving a mixed bid (%)")  ylabel(,grid) ///
ytitle("Probability (%)") xtitle("End-of-May market capitalization rank"))
graph export "$graphs\F4_B3.png", as(pdf) replace
restore

preserve
replace ma1stocko = ma1stocko*100
rdrobust ma1stocko rank if inrange(rank,750,1250) &inrange(cyear,1984,2018), c(1000) p(2)  
rdplot ma1stocko rank if inrange(rank,750,1250) &inrange(cyear,1984,2018), c(1000) p(2) nbins(5) ///
graph_options(title("Probability of receiving a stock-only bid (%)")  ylabel(,grid) ///
ytitle("Probability (%)") xtitle("End-of-May market capitalisation rank"))
graph export "$graphs\F4_B4.png", as(pdf) replace
restore


}
...






*** =================================================================== ***
*** === APPENDIX  === ***
*** =================================================================== ***

*** === Appendix Table A1 : Factor analysis results for the composite index of information asymmetry ===
use "rcfs-data-2-deal-zip",clear 
sum a_lnta a_age_crsp a_n_ana a_tang n_stockoffer a_spread a_varr ab_ac
factor a_lnta a_tang a_age_crsp a_n_ana n_stockoffer a_spread a_varr ab_ac,pcf mineigen(0.1) factor(3) 
capture drop a_f1
predict a_f1
estat kmo
// gen a_info_asym = a_f1 * (-1)
// label variable a_info_asym "acq.information asymetry"
	
sum lnta age_crsp n_ana tang tn_stockoffer spread varr t_ab_ac
factor lnta tang age_crsp n_ana tn_stockoffer spread varr t_ab_ac,pcf mineigen(0.1) factor(3) 
capture drop f1
predict f1
estat kmo
// gen info_asym = f1 * (-1)
// label variable info_asym "tar.information asymetry"




*** === Appendix Table A2 : Market to book decomposition summary statistics by payment methods ===
use "rcfs-data-4-mtb", clear

{ // DECOMPOSING MTB AT THE FIRM-LEVEL
***** ONLY CASH
sum mb a_fse1 a_tsse1 a_lr_vtb1 a_fse2 a_tsse2 a_lr_vtb2 a_fse3 a_tsse3 a_lr_vtb3 if ma1ml==1

***** ONLY MIXED
sum mb a_fse1 a_tsse1 a_lr_vtb1 a_fse2 a_tsse2 a_lr_vtb2 a_fse3 a_tsse3 a_lr_vtb3 if ma1ml==2

***** ONLY STOCK
sum mb a_fse1 a_tsse1 a_lr_vtb1 a_fse2 a_tsse2 a_lr_vtb2 a_fse3 a_tsse3 a_lr_vtb3 if ma1ml==3

}




*** === Appendix Table A3 : Panel sample test of institutional ownership and the targetiveness ===
use "rcfs-data-5-panel",clear

*** LOGIT model
global MyX1 "lnta tbq lev2 cf rnd slg roa1 cer_vw idum_s gdummy"
eststo A: qui logit ma1 d4n_all $MyX1    		 ,clus(gvkey) 
eststo B: qui logit ma1 d4n_all $MyX1 i.fyear i.ffi48 ,clus(gvkey) 
esttab A B , order(d4n_all) drop(19* 2* *fyear* *ffi*  _cons) label $regstats replace

*** Multinomial logit model-FY (Caution: the mlogit command here may take time) 
eststo A: qui  mlogit ma1ml d4n_all   $MyX1 i.fyear i.ffi48
/* marginal effect from the multinomial logit model
forval j = 1/3 {
est res A
margins, dydx(d4n_all) pr(out(`j')) post
est sto mj`j'
}
*/
esttab A, order(d4n_all) drop(19* 2* *fyear* *ffi*  _cons) label $regstats replace

*===== ===== ===== ===== ===== ===== 	End of the DO file 	===== ===== ===== ===== ===== ======* 
